package com.example.ruanshe3.mapper;
import com.example.ruanshe3.model.*;

import java.util.List;

import org.apache.ibatis.annotations.*;
@Mapper
public interface DataMapper {

    //增部分
    //用户
    @Insert("insert into user (userid, username, password, phone) values(#{userid}, #{username}, #{password}, #{phone})")
    int insertuser(@Param("userid") int userid,
               @Param("username") String username,
               @Param("password") String password,
               @Param("phone") String phone);
   //评论
   @Insert("insert into review (reviewid, type, objectid, id, content, reviewtime) values(#{reviewid},#{type},#{objectid},#{id},#{content},#{reviewtime})")
   int insertreview(@Param("reviewid") int reviewid,
                @Param("type") int type,
                @Param("objectid") int objectid,
                @Param("id") int id,
                @Param("content") String content,
                @Param("reviewtime") String reviewtime);
   //上传
   @Insert("insert into upload (uploadid, type, objectid, uploadtime) values(#{uploadid},#{type},#{objectid},#{uploadtime})")
   int insertupload(@Param("uploadid") int uploadid,
                @Param("type") int type,
                @Param("objectid") int objectid,
                @Param("uploadtime") String uploadtime);
   //收藏
   @Insert("insert into collect (collectid, type, objectid) values(#{collectid},#{type},#{objectid})")
   int insertcollect(@Param("collectid") int collectid,
                @Param("type") int type,
                @Param("objectid") int objectid);
   //点赞
   @Insert("insert into likes (likesid, type, objectid) values(#{likesid},#{type},#{objectid})")
   int insertlikes(@Param("likesid") int likesid,
                @Param("type") int type,
                @Param("objectid") int objectid);
   //个体
   @Insert("insert into object (type, objectid, name, image, content, detail) values(#{type},#{objectid},#{name},#{image},#{content},#{detail})")
   int insertobject(@Param("type") int type,
                @Param("objectid") int objectid,
                @Param("name") String name,
                @Param("image") String image,
                @Param("content") String content,
                @Param("detail") String detail);
   
    //删部分
    //用户
    @Delete("delete from user where userid =#{userid}")
    void deleteuser(int userid);
    //评论
    @Delete("delete from review where id=#{id}")
    void deletereview(int id);
    //上传
    @Delete("delete from upload where uploadid=#{uploadid} and type=#{type} and objectid=#{objectid}")
    void deleteupload(upload data);
    //收藏
    @Delete("delete from collect where collectid=#{collectid} and type=#{type} and objectid=#{objectid}")
    void deletecollect(collect data);
    //个体
    @Delete("delete from object where type=#{type} and objectid=#{objectid}")
    void deleteobject(@Param("type") int type, @Param("objectid") int objectid);
    //点赞
    @Delete("delete from likes where likesid=#{likesid} and type=#{type} and objectid=#{objectid}")
    void deletelikes(likes data);
   
    //改部分
    //个体
    @Update("update object set type=#{type}, objectid=#{objectid}, name=#{name}, image=#{image}, content=#{content}, detail=#{detail} where (type,objectid) in (#{type},#{objectid})")
    void updateobject(object data);
    @Update("update upload set uploadid=#{uploadid}, type=#{type}, objectid=#{objectid}, uploadtime=#{uploadtime} where (uploadid,type,objectid) in (#{uploadid},#{type},#{objectid})")
    void updateupload(upload data);
    
    
     //查部分
    //全部个体所有信息
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select * from object where type=#{type}")
        List<object> findObject(@Param("type") int type);
    //按关键字查询个体信息
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select * from object where name like CONCAT('%', #{key}, '%') and type=#{type}")
        List<object> findObjectByKey(@Param("key") String key,@Param("type") int type);
    //查询后按日期排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 inner join upload t2 on t1.type=t2.type and t1.objectid=t2.objectid  where name like CONCAT('%', #{key}, '%') and t1.type=#{type} order by uploadtime Asc,t2.uploadid asc")
        List<object> findObjectByKeySortTimeAsc(@Param("key") String key,@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 inner join upload t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} order by uploadtime Desc,t2.uploadid desc")
        List<object> findObjectByKeySortTimeDesc(@Param("key") String key,@Param("type") int type);
    //查询后按收藏数排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join collect t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} group by t1.type,t1.objectid order by count(*) Asc,t2.collectid asc")
        List<object> findObjectByKeySortCollectAsc(@Param("key") String key,@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join collect t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} group by t1.type,t1.objectid order by count(*) Desc,t2.collectid desc")
        List<object> findObjectByKeySortCollectDesc(@Param("key") String key,@Param("type") int type);
    //查询后按点赞数排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join likes t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} group by t1.type,t1.objectid order by count(*) Asc,t2.likesid asc")
        List<object> findObjectByKeySortLikesAsc(@Param("key") String key,@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join likes t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} group by t1.type,t1.objectid order by count(*) Desc,t2.likesid desc")
        List<object> findObjectByKeySortLikesDesc(@Param("key") String key,@Param("type") int type);
    //查询后按评论数排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,t1.content,detail from object t1 left join review t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} group by t1.type,t1.objectid order by count(*) Asc,t2.reviewid asc")
        List<object> findObjectByKeySortReviewAsc(@Param("key") String key,@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,t1.content,detail from object t1 left join review t2 on t1.type=t2.type and t1.objectid=t2.objectid where name like CONCAT('%', #{key}, '%') and t1.type=#{type} group by t1.type,t1.objectid order by count(*) Desc,t2.reviewid asc")
        List<object> findObjectByKeySortReviewDesc(@Param("key") String key,@Param("type") int type);
    //按日期排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 inner join upload t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} order by uploadtime Asc")
        List<object> findObjectSortTimeAsc(@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 inner join upload t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} order by uploadtime Desc")
        List<object> findObjectSortTimeDesc(@Param("type") int type);
    //按收藏数排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join collect t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} group by t1.type,t1.objectid order by count(*) Asc")
        List<object> findObjectSortCollectAsc(@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join collect t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} group by t1.type,t1.objectid order by count(*) Desc")
        List<object> findObjectSortCollectDesc(@Param("type") int type);
    //按点赞数排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join likes t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} group by t1.type,t1.objectid order by count(*) Asc")
        List<object> findObjectSortLikesAsc(@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,content,detail from object t1 left join likes t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} group by t1.type,t1.objectid order by count(*) Desc")
        List<object> findObjectSortLikesDesc(@Param("type") int type);
    //按评论数排序的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,t1.content,detail from object t1 left join review t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} group by t1.type,t1.objectid order by count(*) Asc")
        List<object> findObjectSortReviewAsc(@Param("type") int type);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.type,t1.objectid,name,image,t1.content,detail from object t1 left join review t2 on t1.type=t2.type and t1.objectid=t2.objectid where t1.type=#{type} group by t1.type,t1.objectid order by count(*) Desc")
        List<object> findObjectSortReviewDesc(@Param("type") int type);
    //某个个体的所有信息
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select * from object  where type=#{type} and objectid=#{objectid}")
        object findOneObject(@Param("type") int type,@Param("objectid") int objectid);
    //对某个个体的评论所有信息
    @Results({
        @Result(property = "reviewid", column = "reviewid"),
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "id", column = "id"),
        @Result(property = "content", column = "content"),
        @Result(property = "reviewtime", column = "reviewtime")
        })
        @Select("select * from review where type=#{type} and objectid=#{objectid}")
        List<review> findReviewByObject(@Param("type") int type,@Param("objectid") int objectid);
    //对某个个体的点赞数
    @Results({
        @Result(property = "likesTotal",column = "count")
        })
        @Select("select count(*) as count from likes where type=#{type} and objectid=#{objectid}")
        likes_total findLikes_total(@Param("type") int type,@Param("objectid") int objectid);
    //对某个个体的收藏数
    @Results({
        @Result(property = "collectTotal",column = "count")
        })
        @Select("select count(*) as count from collect where type=#{type} and objectid=#{objectid}")
        collect_total findCollect_total(@Param("type") int type,@Param("objectid") int objectid);
    //对某个个体的评论数
    @Results({
        @Result(property = "reviewTotal",column = "count")
        })
        @Select("select count(*) as count from review where type=#{type} and objectid=#{objectid}")
        review_total findReview_total(@Param("type") int type,@Param("objectid") int objectid);
    //按关键字查询某个用户收藏的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("select t1.* from object t1 inner join collect t2 on t1.type=t2.type and t1.objectid=t2.objectid where collectid=#{collectid} and t1.type=#{type} and name like CONCAT('%', #{key}, '%')")
        List<object> findObjectByCollect(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    //按日期排序某个用户收藏的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,uploadtime as d from object t1\n" + //
                        "LEFT JOIN upload t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by d asc) as a\n" + //
                        " where (#{collectid},#{type},objectid) in (select * from collect) and type=#{type} and name like CONCAT('%', #{key}, '%') order by d asc")
        List<object> findObjectByCollectSortTimeAsc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
        @Results({
            @Result(property = "type", column = "type"),
            @Result(property = "objectid", column = "objectid"),
            @Result(property = "name", column = "name"),
            @Result(property = "image", column = "image"),
            @Result(property = "content", column = "content"),
            @Result(property = "detail", column = "detail")
            })
            @Select("SELECT *\n" + //
                            "FROM (select t1.*,uploadtime as d from object t1\n" + //
                            "LEFT JOIN upload t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by d desc) as a\n" + //
                            " where (#{collectid},#{type},objectid) in (select * from collect) and type=#{type} and name like CONCAT('%', #{key}, '%') order by d desc")
            List<object> findObjectByCollectSortTimeDesc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    //按收藏排序某个用户收藏的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,t2.collectid,count(*) from object t1\n" + //
                        "LEFT JOIN collect t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by count(*) asc) as a\n" + //
                        "where collectid=#{collectid} and type=#{type} and name like CONCAT('%', #{key}, '%')")
        List<object> findObjectByCollectSortCollectAsc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,t2.collectid,count(*) from object t1\n" + //
                        "LEFT JOIN collect t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by count(*) desc) as a\n" + //
                        "where collectid=#{collectid} and type=#{type} and name like CONCAT('%', #{key}, '%')")
        List<object> findObjectByCollectSortCollectDesc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    //按点赞数排序某个用户收藏的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,count(*) as d from object t1\n" + //
                        "LEFT JOIN likes t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by d asc) as a\n" + //
                        " where (#{collectid},#{type},objectid) in (select * from collect) and type=#{type} and name like CONCAT('%', #{key}, '%') order by d asc")
        List<object> findObjectByCollectSortLikesAsc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,count(*) as d from object t1\n" + //
                        "LEFT JOIN likes t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by d desc) as a\n" + //
                        " where (#{collectid},#{type},objectid) in (select * from collect) and type=#{type} and name like CONCAT('%', #{key}, '%') order by d desc")
        List<object> findObjectByCollectSortLikesDesc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    //按评论数排序某个用户收藏的所有个体
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,count(*) as d from object t1\n" + //
                        "LEFT JOIN review t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by d asc) as a\n" + //
                        " where (#{collectid},#{type},objectid) in (select * from collect) and type=#{type} and name like CONCAT('%', #{key}, '%') order by d asc")
        List<object> findObjectByCollectSortReviewAsc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    @Results({
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "name", column = "name"),
        @Result(property = "image", column = "image"),
        @Result(property = "content", column = "content"),
        @Result(property = "detail", column = "detail")
        })
        @Select("SELECT *\n" + //
                        "FROM (select t1.*,count(*) as d from object t1\n" + //
                        "LEFT JOIN review t2 ON t1.type = t2.type AND t1.objectid = t2.objectid group by t1.type,t1.objectid order by d desc) as a\n" + //
                        " where (#{collectid},#{type},objectid) in (select * from collect) and type=#{type} and name like CONCAT('%', #{key}, '%') order by d desc")
        List<object> findObjectByCollectSortReviewDesc(@Param("collectid") int collectid,@Param("type") int type,@Param("key") String key);
    //用户的所有信息
    //用户id查询
    @Results({
        @Result(property = "userid", column = "userid"),
        @Result(property = "username", column = "username"),
        @Result(property = "password", column = "password"),
        @Result(property = "phone", column = "phone"),
        })
        @Select("select * from user where userid=#{userid}")
        user findUser(@Param("userid") int userid);
    //用户名查询
    @Results({
        @Result(property = "userid", column = "userid"),
        @Result(property = "username", column = "username"),
        @Result(property = "password", column = "password"),
        @Result(property = "phone", column = "phone"),
        })
        @Select("select * from user where username=#{username}")
        user findUserByName(@Param("username") String username);
    //某用户是否点赞过某个体
    @Results({
        @Result(property = "likesid", column = "likesidd"),
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid")
        })
        @Select("select * from likes where likesid=#{likesid} and type=#{type} and objectid=#{objectid}")
        likes findIfLikes(likes data);
    //某用户是否收藏过某个体
    @Results({
        @Result(property = "collectid", column = "collectid"),
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid")
        })
        @Select("select * from collect where collectid=#{collectid} and type=#{type} and objectid=#{objectid}")
        collect findIfCollect(collect data);
    //查询食品或笔记个体数
    @Results({
        @Result(property = "total",column = "count")
        })
        @Select("select count(*) as count from object where type=#{type}")
        total findObject_total(@Param("type") int type);
    //查询用户数
    @Results({
        @Result(property = "total",column = "count")
        })
        @Select("select count(*) as count from user")
        total findUser_total();
    //查询某次上传信息
    @Results({
        @Result(property = "uploadid", column = "uploadid"),
        @Result(property = "type", column = "type"),
        @Result(property = "objectid", column = "objectid"),
        @Result(property = "uploadtime", column = "uploadtime"),
        })
        @Select("select * from upload where type=#{type} and objectid=#{objectid}")
        upload findUpload(@Param("type") int type,@Param("objectid") int objectid);
    
}
